import Vue from "vue";
import App from "./App.vue";
// 导入vue-router
import VueRouter from "vue-router";
import HmLogin from "@/views/HmLogining.vue";
import HmRegister from "@/views/HmRegisterIng.vue";
import HmHomepage from "@/views/HmHomepage.vue";
import HmArticle from "@/views/HmArticle.vue";
import HmCollect from "@/views/HmCollect.vue";
import HmUser from "@/views/HmUser.vue";
import HmLike from "@/views/HmLike.vue";
import Detail from "@/views/Detail.vue";
import Vant from "vant";
import "vant/lib/index.css";
// 把vant中所有的组件都导入了
Vue.use(Vant); // 项目中启用vant组件库  安装

// 创建全局组件
import HmHeader from "@/components/HmHeader.vue";
Vue.component("HmHeader", HmHeader);
Vue.use(VueRouter);

// 创建路由对象
const router = new VueRouter({
  linkActiveClass: "active",
  linkExactActiveClass: "ex-active",
  routes: [
    //一级路由
    {
      path: "/Detail",
      component: Detail,
    },
    {
      path: "/login",
      component: HmLogin,
    },
    {
      path: "/register",
      component: HmRegister,
    },
    {
      path: "/home",
      component: HmHomepage,
      children: [
        {
          //子路由必须以父路由路径开头
          path: "/home/Article",
          component: HmArticle,
        },
        {
          path: "/home/Collect",
          component: HmCollect,
        },
        {
          path: "/home/User",
          component: HmUser,
        },
        {
          path: "/home/Like",
          component: HmLike,
        },
      ],
    },
  ],
});

Vue.config.productionTip = false;

new Vue({
  render: (h) => h(App),
  router,
}).$mount("#app");
